<%--
  Created by IntelliJ IDEA.
  User: 698
  Date: 2025/6/25
  Time: 上午10:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="css/styless.css">
    <script type="text/javascript">
        function reloadImage(img) {
            img.src = "/images?flag=" + Math.random();
        }
    </script>
</head>
<body>
<nav class="navbar">
    <ul class="nav-list">
        <li><a href="index.jsp" class="nav-link">首页</a></li>
        <li><a href="about.jsp" class="nav-link">关于我们</a></li>
        <%
            if (session.getAttribute("login_account") != null){ %>
        <li><a href="book1.jsp" class="nav-link">图书列表</a></li>
        <li><a href="profile.jsp" class="nav-link">借阅信息</a></li>
        <li><a href="userxx.jsp" class="nav-link">我的账户</a></li>
        <li><a href="quit.jsp" class="nav-link">登出</a></li>
        <% } else { %>
        <!-- 否则显示登录和注册链接 -->
        <li><a href="login.jsp" class="nav-link">登录</a></li>
        <li><a href="register.jsp" class="nav-link">注册</a></li>
        <li><a href="book1.jsp" class="nav-link">图书列表</a></li>
        <% } %>
    </ul>
</nav>
<form action="<%=pageContext.getServletContext().getContextPath()%>/userServlet" >

    <td><input type="hidden"  id="actionType" name="actionType" value="user_add"></td>
    用户名： <input type="text" id="username" name= "username" ><br>
    新密码：&nbsp;<input type="password" id="password" name= "password" ><br>
    邮&nbsp;箱 ：&nbsp;&nbsp;&nbsp;<input type="text" id="email" name= "email" ><br>
    验证码：&nbsp;<input type="text" id="code" name= "code" ><br>
    <img src="<%=request.getContextPath()%>/images?flag=<%=Math.random() %>" alt="看不清，换一张" onclick="reloadImage(this)"><br>

    <input type="button" value="注册" onclick="check_frm()">

</form>
<script type="text/javascript">
    function check_frm(){
        var user_acc = document.getElementById("username")
        var user_acc_value = user_acc.value;
        var restrictedChars = /[<>'"&]/; // 限制字符
        if (restrictedChars.test(user_acc_value)) {
            alert("不允许输入HTML标签或特殊字符！");
            return;
        }
        if (user_acc_value == "") {
            alert("请输入账号\n" + user_acc_value);
            return;
        }

        var login_pwd = document.getElementById("password")
        var login_pwd_value = login_pwd.value;
        if (login_pwd_value == "") {
            alert("请输入密码");
            return;
        }
        var email = document.getElementById("email")
        var email_value = email.value;
        if (email_value == "") {
            alert("请输入邮箱");
            return;
        }
        var code= document.getElementById("code")
        var code_value = code.value;
        var sessionCode=<%=request.getSession().getAttribute("sessionCode")%>;
        if (code_value ==sessionCode) {

        }

        document.forms[0].submit();
    }
</script>
</body>
</html>
